<template>
    <div class="container scopClass">
        <h3>物料管理</h3>
        <el-tabs v-model="activeName" type="border-card" style="margin-top:20px;" @tab-click="handleClick">
            <el-tab-pane v-if='switchHeadTab == "生产系统"' label="中药材" name="中药材">
                <el-row style="margin:20px 0;">
                    <el-col :span="7">
                        <el-input style="border-radius: 0 5px 5px 0;width:300px;" placeholder="请输入关键词"  v-model.trim="searchName1">
                            <i slot="prefix" class="el-input__icon el-icon-search"></i>
                            <el-button slot="append" @click="handleSearch1">搜索</el-button>
                        </el-input>
                    </el-col>
                  <el-button style="float:right; margin-right: 10px" @click="download1">导出数据</el-button>
                    <el-button style="float:right; margin-right: 10px" @click="download">模板下载</el-button>
                    <el-upload
                        class="upload-daoru"
                        ref="upload"
                        :action="action"
                        :on-change="uploadonchange"
                        accept=".xlsx,.xls"
                        :show-file-list='false'
                        :auto-upload="false"
                        >
                        <el-button slot="trigger" size="small">导入模板</el-button>
                    </el-upload>
                    <router-link :to="{path:'/materialsManagement/added',query: {type: '中药材'}}"><el-button type="primary" v-if="added" style="float:right; margin-right: 10px">新建物料</el-button></router-link>
                </el-row>
                <el-table
                    :data="tableData"
                    border
                    ref="multipleTable"
                    header-cell-class-name="table-header"
                >
                    <!-- <el-table-column prop="fromFactoryName" sortable label="厂区标识"></el-table-column> -->
                    <el-table-column prop="breedName" sortable label="名称"></el-table-column>
                    <el-table-column prop="materialType" sortable label="物料类型"></el-table-column>
                    <el-table-column prop="materialCode" sortable label="物料代码"></el-table-column>
                    <el-table-column prop="ypCode" sortable label="药品标识码"></el-table-column>
                    <el-table-column prop="status" sortable label="状态">
                        <template slot-scope="scope">
                            {{scope.row.status == 0?'启用':'禁用'}}
                        </template>
                    </el-table-column>
                    <el-table-column label="操作" width="150" align="center">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
								v-if="edit"
                                @click="handleEdit(scope.$index, scope.row)"
                            >编辑</el-button>
                            <el-button
                                type="text"
                                @click="handleView(scope.$index, scope.row)"
                            >查看</el-button>
                            <el-button
                                v-if="scope.row.status == 0"
                                type="text"
                                @click="isOk(scope.$index, scope.row)"
                            >禁用</el-button>
                            <el-button
                                v-if="scope.row.status == 1"
                                type="text"
                                @click="isNo(scope.$index, scope.row)"
                            >启用</el-button>
                            <!-- <el-button
                                type="text"
                                @click="handleDelete(scope.$index, scope.row)"
                            >删除</el-button> -->
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination layout="total, prev, pager, next, jumper" :page-size="pagesize1" @current-change="handleCurrentChange1" :total="total1" :current-page.sync="currentPage1" style="margin-top:20px"></el-pagination>
            </el-tab-pane>
            <el-tab-pane v-if='switchHeadTab == "生产系统"' label="辅料" name="辅料">
                <el-row style="margin:20px 0;">
                    <el-col :span="7">
                        <el-input style="border-radius: 0 5px 5px 0;width:300px;" placeholder="请输入关键词"  v-model.trim="searchName2">
                            <i slot="prefix" class="el-input__icon el-icon-search"></i>
                            <el-button slot="append" @click="handleSearch2">搜索</el-button>
                        </el-input>
                    </el-col>
                  <el-button style="float:right; margin-right: 10px" @click="download1">导出数据</el-button>
                    <el-button style="float:right; margin-right: 10px" @click="download">模板下载</el-button>
                    <el-upload
                        class="upload-daoru"
                        ref="upload"
                        :action="action"
                        :on-change="uploadonchange"
                        accept=".xlsx,.xls"
                        :show-file-list='false'
                        :auto-upload="false"
                        >
                        <el-button slot="trigger" size="small">导入模板</el-button>
                    </el-upload>
                    <router-link :to="{path:'/materialsManagement/added',query: {type: '辅料'}}"><el-button type="primary" v-if="added" style="float:right; margin-right: 10px">新建物料</el-button></router-link>
                </el-row>
                <el-table
                    :data="tableData"
                    border
                    ref="multipleTable"
                    header-cell-class-name="table-header"
                >
                    <!-- <el-table-column prop="fromFactoryName" sortable label="厂区标识"></el-table-column> -->
                    <el-table-column prop="breedName" sortable label="名称"></el-table-column>
                    <el-table-column prop="materialType" sortable label="物料类型"></el-table-column>
                    <el-table-column prop="materialCode" sortable label="物料代码"></el-table-column>
                    <el-table-column prop="ypCode" sortable label="药品标识码"></el-table-column>
                    <el-table-column prop="status" sortable label="状态">
                        <template slot-scope="scope">
                            {{scope.row.status == 0?'启用':'禁用'}}
                        </template>
                    </el-table-column>
                    <el-table-column label="操作" width="150" align="center">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
								v-if="edit"
                                @click="handleEdit(scope.$index, scope.row)"
                            >编辑</el-button>
                            <el-button
                                type="text"
                                @click="handleView(scope.$index, scope.row)"
                            >查看</el-button>
                            <el-button
                                v-if="scope.row.status == 0"
                                type="text"
                                @click="isOk(scope.$index, scope.row)"
                            >禁用</el-button>
                            <el-button
                                v-if="scope.row.status == 1"
                                type="text"
                                @click="isNo(scope.$index, scope.row)"
                            >启用</el-button>
                            <!-- <el-button
                                type="text"
                                @click="handleDelete(scope.$index, scope.row)"
                            >删除</el-button> -->
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination layout="total, prev, pager, next, jumper" :page-size="pagesize2" @current-change="handleCurrentChange2" :total="total2" :current-page.sync="currentPage2" style="margin-top:20px"></el-pagination>
            </el-tab-pane>
            <el-tab-pane v-if='switchHeadTab == "中药饮片"' label="中药饮片(半成品)" name="中药饮片(半成品)">
                <el-row style="margin:20px 0;">
                    <el-col :span="7">
                        <el-input style="border-radius: 0 5px 5px 0;width:300px;" placeholder="请输入关键词"  v-model.trim="searchNamezybcp">
                            <i slot="prefix" class="el-input__icon el-icon-search"></i>
                            <el-button slot="append" @click="handleSearchzybcp">搜索</el-button>
                        </el-input>
                    </el-col>
                    <el-button style="float:right; margin-right: 10px" @click="download1">导出数据</el-button>
                    <el-button style="float:right; margin-right: 10px" @click="download">模板下载</el-button>
                    <el-upload
                        class="upload-daoru"
                        ref="upload"
                        :action="action"
                        :on-change="uploadonchange"
                        accept=".xlsx,.xls"
                        :show-file-list='false'
                        :auto-upload="false"
                    >
                        <el-button slot="trigger" size="small">导入模板</el-button>
                    </el-upload>
                    <router-link :to="{path:'/materialsManagement/added',query: {type: '中药饮片(半成品)'}}"><el-button type="primary" v-if="added" style="float:right; margin-right: 10px">新建物料</el-button></router-link>
                </el-row>
                <el-table
                    :data="tableData"
                    border
                    ref="multipleTable"
                    header-cell-class-name="table-header"
                >
                    <!-- <el-table-column prop="fromFactoryName" sortable label="厂区标识"></el-table-column> -->
                    <el-table-column prop="breedName" sortable label="名称"></el-table-column>
                    <el-table-column prop="materialType" sortable label="物料类型"></el-table-column>
                    <el-table-column prop="materialCode" sortable label="物料代码"></el-table-column>
                    <el-table-column prop="ypCode" sortable label="药品标识码"></el-table-column>
                    <el-table-column prop="status" sortable label="状态">
                        <template slot-scope="scope">
                            {{scope.row.status == 0?'启用':'禁用'}}
                        </template>
                    </el-table-column>
                    <el-table-column label="操作" width="150" align="center">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                v-if="edit"
                                @click="handleEdit(scope.$index, scope.row)"
                            >编辑</el-button>
                            <el-button
                                type="text"
                                @click="handleView(scope.$index, scope.row)"
                            >查看</el-button>
                            <el-button
                                v-if="scope.row.status == 0"
                                type="text"
                                @click="isOk(scope.$index, scope.row)"
                            >禁用</el-button>
                            <el-button
                                v-if="scope.row.status == 1"
                                type="text"
                                @click="isNo(scope.$index, scope.row)"
                            >启用</el-button>
                            <!-- <el-button
                                type="text"
                                @click="handleDelete(scope.$index, scope.row)"
                            >删除</el-button> -->
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination layout="total, prev, pager, next, jumper" :page-size="pagesizezybcp" @current-change="handleCurrentChangezybcp" :total="totalzybcp" :current-page.sync="currentPagezybcp" style="margin-top:20px"></el-pagination>
            </el-tab-pane>

            <el-tab-pane v-if='switchHeadTab == "生产系统"' label="提取饮片" name="提取饮片">
                <el-row style="margin:20px 0;">
                    <el-col :span="7">
                        <el-input style="border-radius: 0 5px 5px 0;width:300px;" placeholder="请输入关键词"  v-model.trim="searchName3">
                            <i slot="prefix" class="el-input__icon el-icon-search"></i>
                            <el-button slot="append" @click="handleSearch3">搜索</el-button>
                        </el-input>
                    </el-col>
                  <el-button style="float:right; margin-right: 10px" @click="download1">导出数据</el-button>
                    <el-button style="float:right; margin-right: 10px" @click="download">模板下载</el-button>
                    <el-upload
                        class="upload-daoru"
                        ref="upload"
                        :action="action"
                        :on-change="uploadonchange"
                        accept=".xlsx,.xls"
                        :show-file-list='false'
                        :auto-upload="false"
                        >
                        <el-button slot="trigger" size="small">导入模板</el-button>
                    </el-upload>
                    <router-link :to="{path:'/materialsManagement/added',query: {type: '提取饮片'}}"><el-button type="primary" v-if="added" style="float:right; margin-right: 10px">新建物料</el-button></router-link>
                </el-row>
                <el-table
                    :data="tableData"
                    border
                    ref="multipleTable"
                    header-cell-class-name="table-header"
                >
                    <!-- <el-table-column prop="fromFactoryName" sortable label="厂区标识"></el-table-column> -->
                    <el-table-column prop="breedName" sortable label="名称"></el-table-column>
                    <el-table-column prop="materialType" sortable label="物料类型"></el-table-column>
                    <el-table-column prop="materialCode" sortable label="物料代码"></el-table-column>
                    <el-table-column prop="ypCodeStandard" sortable label="标准类型"></el-table-column>
                    <el-table-column prop="ypCode" sortable label="药品标识码"></el-table-column>
                    <el-table-column prop="status" sortable label="状态">
                        <template slot-scope="scope">
                            {{scope.row.status == 0?'启用':'禁用'}}
                        </template>
                    </el-table-column>
                    <el-table-column label="操作" width="150" align="center">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
								v-if="edit"
                                @click="handleEdit(scope.$index, scope.row)"
                            >编辑</el-button>
                            <el-button
                                type="text"
                                @click="handleView(scope.$index, scope.row)"
                            >查看</el-button>
                            <el-button
                                v-if="scope.row.status == 0"
                                type="text"
                                @click="isOk(scope.$index, scope.row)"
                            >禁用</el-button>
                            <el-button
                                v-if="scope.row.status == 1"
                                type="text"
                                @click="isNo(scope.$index, scope.row)"
                            >启用</el-button>
                            <!-- <el-button
                                type="text"
                                @click="handleDelete(scope.$index, scope.row)"
                            >删除</el-button> -->
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination layout="total, prev, pager, next, jumper" :page-size="pagesize3" @current-change="handleCurrentChange3" :total="total3" :current-page.sync="currentPage3" style="margin-top:20px"></el-pagination>
            </el-tab-pane>
			<el-tab-pane v-if='switchHeadTab == "生产系统"' label="配方颗粒(浸膏粉)" name="配方颗粒(浸膏粉)">
			    <el-row style="margin:20px 0;">
			        <el-col :span="7">
			            <el-input style="border-radius: 0 5px 5px 0;width:300px;" placeholder="请输入关键词"  v-model.trim="searchName5">
			                <i slot="prefix" class="el-input__icon el-icon-search"></i>
			                <el-button slot="append" @click="handleSearch5">搜索</el-button>
			            </el-input>
			        </el-col>
            <el-button style="float:right; margin-right: 10px" @click="download1">导出数据</el-button>
			        <el-button style="float:right; margin-right: 10px" @click="download">模板下载</el-button>
			        <el-upload
			            class="upload-daoru"
			            ref="upload"
			            :action="action"
			            :on-change="uploadonchange"
			            accept=".xlsx,.xls"
			            :show-file-list='false'
			            :auto-upload="false"
			            >
			            <el-button slot="trigger" size="small">导入模板</el-button>
			        </el-upload>
			        <router-link :to="{path:'/materialsManagement/added',query: {type: '配方颗粒(浸膏粉)'}}"><el-button type="primary" v-if="added" style="float:right; margin-right: 10px">新建物料</el-button></router-link>
			    </el-row>
			    <el-table
			        :data="tableData"
			        border
			        ref="multipleTable"
			        header-cell-class-name="table-header"
			    >
              <!-- <el-table-column prop="fromFactoryName" sortable label="厂区标识"></el-table-column> -->
			        <el-table-column prop="breedName" sortable label="名称"></el-table-column>
			        <el-table-column prop="materialType" sortable label="物料类型"></el-table-column>
			        <el-table-column prop="materialCode" sortable label="物料代码"></el-table-column>
                    <el-table-column prop="ypCodeStandard" sortable label="标准类型"></el-table-column>
			        <el-table-column prop="ypCode" sortable label="药品标识码"></el-table-column>
			        <el-table-column prop="status" sortable label="状态">
			            <template slot-scope="scope">
			                {{scope.row.status == 0?'启用':'禁用'}}
			            </template>
			        </el-table-column>
			        <el-table-column label="操作" width="150" align="center">
			            <template slot-scope="scope">
			                <el-button
			                    type="text"
								v-if="edit"
			                    @click="handleEdit(scope.$index, scope.row)"
			                >编辑</el-button>
			                <el-button
			                    type="text"
			                    @click="handleView(scope.$index, scope.row)"
			                >查看</el-button>
			                <el-button
			                    v-if="scope.row.status == 0"
			                    type="text"
			                    @click="isOk(scope.$index, scope.row)"
			                >禁用</el-button>
			                <el-button
			                    v-if="scope.row.status == 1"
			                    type="text"
			                    @click="isNo(scope.$index, scope.row)"
			                >启用</el-button>
			                <!-- <el-button
			                    type="text"
			                    @click="handleDelete(scope.$index, scope.row)"
			                >删除</el-button> -->
			            </template>
			        </el-table-column>
			    </el-table>
			    <el-pagination layout="total, prev, pager, next, jumper" :page-size="pagesize1" @current-change="handleCurrentChange5" :total="total5" :current-page.sync="currentPage5" style="margin-top:20px"></el-pagination>
			</el-tab-pane>
            <el-tab-pane v-if='switchHeadTab == "生产系统"' label="配方颗粒(颗粒)" name="配方颗粒(颗粒)">
                <el-row style="margin:20px 0;">
                    <el-col :span="7">
                        <el-input style="border-radius: 0 5px 5px 0;width:300px;" placeholder="请输入关键词"  v-model.trim="searchName6">
                            <i slot="prefix" class="el-input__icon el-icon-search"></i>
                            <el-button slot="append" @click="handleSearch6">搜索</el-button>
                        </el-input>
                    </el-col>
                  <el-button style="float:right; margin-right: 10px" @click="download1">导出数据</el-button>
                    <el-button style="float:right; margin-right: 10px" @click="download">模板下载</el-button>
                    <el-upload
                        class="upload-daoru"
                        ref="upload"
                        :action="action"
                        :on-change="uploadonchange"
                        accept=".xlsx,.xls"
                        :show-file-list='false'
                        :auto-upload="false"
                    >
                        <el-button slot="trigger" size="small">导入模板</el-button>
                    </el-upload>
                    <router-link :to="{path:'/materialsManagement/added',query: {type: '配方颗粒(颗粒)'}}"><el-button type="primary" v-if="added" style="float:right; margin-right: 10px">新建物料</el-button></router-link>
                </el-row>
                <el-table
                    :data="tableData"
                    border
                    ref="multipleTable"
                    header-cell-class-name="table-header"
                >
                    <el-table-column prop="breedName" sortable label="名称"></el-table-column>
                    <el-table-column prop="materialType" sortable label="物料类型"></el-table-column>
                    <el-table-column prop="materialCode" sortable label="物料代码"></el-table-column>
                    <el-table-column prop="ypCodeStandard" sortable label="标准类型"></el-table-column>
                    <el-table-column prop="ypCode" sortable label="药品标识码"></el-table-column>
                    <el-table-column prop="status" sortable label="状态">
                        <template slot-scope="scope">
                            {{scope.row.status == 0?'启用':'禁用'}}
                        </template>
                    </el-table-column>
                    <el-table-column label="操作" width="150" align="center">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                v-if="edit"
                                @click="handleEdit(scope.$index, scope.row)"
                            >编辑</el-button>
                            <el-button
                                type="text"
                                @click="handleView(scope.$index, scope.row)"
                            >查看</el-button>
                            <el-button
                                v-if="scope.row.status == 0"
                                type="text"
                                @click="isOk(scope.$index, scope.row)"
                            >禁用</el-button>
                            <el-button
                                v-if="scope.row.status == 1"
                                type="text"
                                @click="isNo(scope.$index, scope.row)"
                            >启用</el-button>
                            <!-- <el-button
                                type="text"
                                @click="handleDelete(scope.$index, scope.row)"
                            >删除</el-button> -->
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination layout="total, prev, pager, next, jumper" :page-size="pagesize6" @current-change="handleCurrentChange6" :total="total6" :current-page.sync="currentPage6" style="margin-top:20px"></el-pagination>
            </el-tab-pane>
            <el-tab-pane v-if='switchHeadTab == "生产系统"' label="配方颗粒" name="配方颗粒">
                <el-row style="margin:20px 0;">
                    <el-col :span="7">
                        <el-input style="border-radius: 0 5px 5px 0;width:300px;" placeholder="请输入关键词"  v-model.trim="searchName4">
                            <i slot="prefix" class="el-input__icon el-icon-search"></i>
                            <el-button slot="append" @click="handleSearch4">搜索</el-button>
                        </el-input>
                    </el-col>

                  <el-button style="float:right; margin-right: 10px" @click="download1">导出数据</el-button>
                    <el-button style="float:right; margin-right: 10px" @click="download">模板下载</el-button>
                    <el-upload
                        class="upload-daoru"
                        ref="upload"
                        :action="action"
                        :on-change="uploadonchange"
                        accept=".xlsx,.xls"
                        :show-file-list='false'
                        :auto-upload="false"
                        >
                        <el-button slot="trigger" size="small">导入模板</el-button>
                    </el-upload>
                    <router-link :to="{path:'/materialsManagement/added',query: {type: '配方颗粒'}}"><el-button type="primary" v-if="added" style="float:right; margin-right: 10px">新建物料</el-button></router-link>
                </el-row>
                <el-table
                    :data="tableData"
                    border
                    ref="multipleTable"
                    header-cell-class-name="table-header"
                >
                    <!-- <el-table-column prop="fromFactoryName" sortable label="厂区标识"></el-table-column> -->
                    <el-table-column prop="breedName" sortable label="名称"></el-table-column>
                    <el-table-column prop="materialType" sortable label="物料类型"></el-table-column>
                    <el-table-column prop="inventoryType" sortable label="产品大类"></el-table-column>
<!--                    <el-table-column prop="materialCode" sortable label="物料代码"></el-table-column>-->
                    <el-table-column prop="ypCodeStandard" sortable label="标准类型"></el-table-column>
                    <el-table-column prop="ypCode" sortable label="药品标识码"></el-table-column>
                    <el-table-column prop="prodRecordCode" sortable label="上市备案号"></el-table-column>
                    <el-table-column prop="status" sortable label="状态">
                        <template slot-scope="scope">
                            {{scope.row.status == 0?'启用':'禁用'}}
                        </template>
                    </el-table-column>
                    <el-table-column label="操作" width="150" align="center">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
								                v-if="edit"
                                @click="handleEdit(scope.$index, scope.row)"
                            >编辑</el-button>
                            <el-button
                                type="text"
                                @click="handleView(scope.$index, scope.row)"
                            >查看</el-button>
                            <el-button
                                v-if="scope.row.status == 0"
                                type="text"
                                @click="isOk(scope.$index, scope.row)"
                            >禁用</el-button>
                            <el-button
                                v-if="scope.row.status == 1"
                                type="text"
                                @click="isNo(scope.$index, scope.row)"
                            >启用</el-button>
                            <!-- <el-button
                                type="text"
                                @click="handleDelete(scope.$index, scope.row)"
                            >删除</el-button> -->
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination layout="total, prev, pager, next, jumper" :page-size="pagesize4" @current-change="handleCurrentChange4" :total="total4" :current-page.sync="currentPage4" style="margin-top:20px"></el-pagination>
            </el-tab-pane>
            <el-tab-pane v-if='switchHeadTab == "中药饮片"' label="中药饮片" name="中药饮片">
                <el-row style="margin:20px 0;">
                    <el-col :span="7">
                        <el-input style="border-radius: 0 5px 5px 0;width:300px;" placeholder="请输入关键词"  v-model.trim="searchNamezy">
                            <i slot="prefix" class="el-input__icon el-icon-search"></i>
                            <el-button slot="append" @click="handleSearchzy">搜索</el-button>
                        </el-input>
                    </el-col>
                    <el-button style="float:right; margin-right: 10px" @click="download1">导出数据</el-button>
                    <el-button style="float:right; margin-right: 10px" @click="download">模板下载</el-button>
                    <el-upload
                        class="upload-daoru"
                        ref="upload"
                        :action="action"
                        :on-change="uploadonchange"
                        accept=".xlsx,.xls"
                        :show-file-list='false'
                        :auto-upload="false"
                    >
                        <el-button slot="trigger" size="small">导入模板</el-button>
                    </el-upload>
                    <router-link :to="{path:'/materialsManagement/added',query: {type: '中药饮片'}}"><el-button type="primary" v-if="added" style="float:right; margin-right: 10px">新建物料</el-button></router-link>
                </el-row>
                <el-table
                    :data="tableData"
                    border
                    ref="multipleTable"
                    header-cell-class-name="table-header"
                >
                    <!-- <el-table-column prop="fromFactoryName" sortable label="厂区标识"></el-table-column> -->
                    <el-table-column prop="breedName" sortable label="名称"></el-table-column>
                    <el-table-column prop="materialType" sortable label="物料类型"></el-table-column>
                    <el-table-column prop="materialCode" sortable label="物料代码"></el-table-column>
                    <el-table-column prop="ypCode" sortable label="药品标识码"></el-table-column>
                    <el-table-column prop="status" sortable label="状态">
                        <template slot-scope="scope">
                            {{scope.row.status == 0?'启用':'禁用'}}
                        </template>
                    </el-table-column>
                    <el-table-column label="操作" width="150" align="center">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                v-if="edit"
                                @click="handleEdit(scope.$index, scope.row)"
                            >编辑</el-button>
                            <el-button
                                type="text"
                                @click="handleView(scope.$index, scope.row)"
                            >查看</el-button>
                            <el-button
                                v-if="scope.row.status == 0"
                                type="text"
                                @click="isOk(scope.$index, scope.row)"
                            >禁用</el-button>
                            <el-button
                                v-if="scope.row.status == 1"
                                type="text"
                                @click="isNo(scope.$index, scope.row)"
                            >启用</el-button>
                            <!-- <el-button
                                type="text"
                                @click="handleDelete(scope.$index, scope.row)"
                            >删除</el-button> -->
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination layout="total, prev, pager, next, jumper" :page-size="pagesizezy" @current-change="handleCurrentChangezy" :total="totalzy" :current-page.sync="currentPagezy" style="margin-top:20px"></el-pagination>
            </el-tab-pane>

        </el-tabs>
    </div>
</template>

<script>
import {materialBreed_list,materialBreed_delete,materialBreed_inmaterial,materialBreed_updateStatus} from "@/request/api";
import uploadFile from '../../../common/uploadfile';
import axios from "axios";
import {check_daoru, exportSellRecordTemp, mater_daoru} from "../../../../request/api";
import {mapState} from 'vuex'
    export default {
        components: {
            uploadFile
        },
        data() {
            return {
                activeName: '',
                materialType: '',
                searchName1: '',
                searchName2: '',
                searchName3: '',
                searchName4: '',
				searchName5: '',
                searchNamezy:'',
                pagesizezybcp:10,
                pagesizezy:10,
                searchNamezybcp:'',
                currentPagezy:1,
                currentPagezybcp:1,
                totalzy:0,
                totalzybcp:0,
                tableData: [],
                total1: 0,
                currentPage1:1,
                pagesize1:10,
                total2: 0,
                currentPage2:1,
                pagesize2:10,
                total3: 0,
                currentPage3:1,
                pagesize3:10,
                total4: 0,
                currentPage4:1,


                pagesize5:10,
                total5: 0,
				currentPage5:1,
                pagesize6:10,
                total6: 0,
                currentPage6:1,
                pagesize4:10,
                listUrl: '',
                action: '',
                added:true,
				edit:true,
                searchName6:''
            };
        },
        computed:{
            ...mapState(['switchHeadTab'])
        },
        created(){
            var data = JSON.stringify(this.$store.state.wl)
            var a = "新增"
			var b = "编辑"
            if(data.indexOf(a) != -1){
                this.added = true
            }else{
                this.added = false
            }
			if(data.indexOf(b) != -1){
			    this.edit = true
			}else{
			    this.edit = false
			}
        },
        mounted(){
            console.log(this.$store.state.storName)

            if(this.$store.state.storName){
                if(this.$store.state.storName == '中药材'){
                    this.activeName = '中药材'
                    this.init1()
                } else if(this.$store.state.storName == '辅料'){
                    this.activeName = '辅料'
                    this.init2()
                } else if(this.$store.state.storName == '提取饮片'){
                    this.activeName = '提取饮片'
                    this.init3()
                } else if(this.$store.state.storName == '配方颗粒'){
                    this.activeName = '配方颗粒'
                    this.init4()
                }else if(this.$store.state.storName == '配方颗粒(浸膏粉)'){
                    this.activeName = '配方颗粒(浸膏粉)'
                    this.init5()
                }else if(this.$store.state.storName == '中药饮片'){
                    this.activeName = '中药饮片'
                    this.materialType = '中药饮片'
                    this.initzy()
                }else if(this.$store.state.storName == '中药饮片(半成品)'){
                    this.activeName = '中药饮片(半成品)'
                    this.materialType = '中药饮片(半成品)'
                    this.initzybcp()
                }  else if(this.$store.state.storName == '配方颗粒(颗粒)'){
                    this.activeName = '配方颗粒(颗粒)'
                    this.init6()
                }
            }else{
                if(!this.$store.state.storName && this.switchHeadTab =='中药饮片'){
                    this.activeName = '中药饮片(半成品)'
                    this.initzybcp()
                }else{
                    this.activeName = '中药材'
                    this.init1()
                }
            }

        },
        destroyed: function () {
            this.$store.commit("setStorName","")
        },
        methods: {
          download12(){
            axios({
              method: 'GET',
              url: '/materialBreed/exportSellRecordTemp',
              responseType: 'blob'
            }).then(res=>{
              // console.log(res)
              this.downloadFile(res, '数据.xls')
            }).catch(err=>{
              // console.log(err)
            })
          },

          uploadonchange12(file) {
            let formData = new FormData();
            formData.append('file', file.raw);
            let config = {
              headers:{'Content-Type':'multipart/form-data'}
            };
            exportSellRecordTemp(formData).then((res) =>{
              if (res.code == 200) {
                this.$notify({
                  title: '操作成功',
                  message: '导入成功',
                  type: 'success'
                });
                this.init()
              } else{
                this.$notify.error({
                  title: '操作失败',
                  message: '导入失败',
                  type: 'error'
                });
              }
            })
          },
          download1(){
            // window.location.href = "http://" + window.location.host + "/order/out";
            // window.location.href = "http://171.221.199.35:10109/order/out"
            axios({
              method: 'POST',
              url: '/materialBreed/export',
              data:{
                materialType:this.activeName
              },
              responseType: 'blob'
            }).then(res=>{
              //  console.log(res)
              // let blob = new Blob([res.data], {type: "application/vnd.ms-excel"});
              // let url = window.URL.createObjectURL(blob);
              // window.location.href = url;
              this.downloadFile(res,  this.activeName+'.xls')

            }).catch(err=>{
              // console.log(err)
            })

          },
          downloadFile(res, fileName) {
            let blob = new Blob([res.data]);
            if (!fileName) {
              fileName = res.headers['content-disposition'].split('filename=').pop();
            }
            if ('msSaveOrOpenBlob' in navigator) {
              window.navigator.msSaveOrOpenBlob(blob, fileName);
            } else {
              const elink = document.createElement('a');
              elink.download = fileName;
              elink.style.display = 'none';
              elink.href = URL.createObjectURL(blob);
              document.body.appendChild(elink);
              elink.click();
              URL.revokeObjectURL(elink.href);
              document.body.removeChild(elink);
            }
          },
            // 调用接口
            init1(){
                materialBreed_list({
                    materialType: '中药材',
                    searchName: this.searchName1,
                    page: this.currentPage1,
                }).then((res) =>{
                    this.tableData = res.rows
                    this.total1 = res.total
                })
            },
            init2(){
                materialBreed_list({
                    materialType: '辅料',
                    searchName: this.searchName2,
                    page: this.currentPage2,
                }).then((res) =>{
                    this.tableData = res.rows
                    this.total2 = res.total
                })
            },
            init3(){
                materialBreed_list({
                    materialType: '提取饮片',
                    searchName: this.searchName3,
                    page: this.currentPage3,
                }).then((res) =>{
                    this.tableData = res.rows
                    this.total3 = res.total
                    for(var i=0;i<this.tableData.length;i++){
                        if(this.tableData[i].ypCodeStandard == 1){
                            this.tableData[i].ypCodeStandard = "国标"
                        }else if(this.tableData[i].ypCodeStandard == 2){
                            this.tableData[i].ypCodeStandard = "省标"
                        }
                    }
                })
            },
            init4(){
                materialBreed_list({
                    materialType: '配方颗粒',
                    searchName: this.searchName4,
                    page: this.currentPage4,
                }).then((res) =>{
                    this.tableData = res.rows
                    this.total4 = res.total
                    for(var i=0;i<this.tableData.length;i++){
                        if(this.tableData[i].ypCodeStandard == 1){
                            this.tableData[i].ypCodeStandard = "国标"
                        }else if(this.tableData[i].ypCodeStandard == 2){
                            this.tableData[i].ypCodeStandard = "省标"
                        }
                    }
                })
            },
            init6(){
                materialBreed_list({
                    materialType: '配方颗粒(颗粒)',
                    searchName: this.searchName6,
                    page: this.currentPage6,
                }).then((res) =>{
                    this.tableData = res.rows
                    this.total6 = res.total
                    for(var i=0;i<this.tableData.length;i++){
                        if(this.tableData[i].ypCodeStandard == 1){
                            this.tableData[i].ypCodeStandard = "国标"
                        }else if(this.tableData[i].ypCodeStandard == 2){
                            this.tableData[i].ypCodeStandard = "省标"
                        }
                    }
                })
            },
            initzy(){
                materialBreed_list({
                    materialType: '中药饮片',
                    searchName: this.searchNamezy,
                    page: this.currentPagezy,
                }).then((res) =>{
                    this.tableData = res.rows
                    this.totalzy = res.total
                    for(var i=0;i<this.tableData.length;i++){
                        if(this.tableData[i].ypCodeStandard == 1){
                            this.tableData[i].ypCodeStandard = "国标"
                        }else if(this.tableData[i].ypCodeStandard == 2){
                            this.tableData[i].ypCodeStandard = "省标"
                        }
                    }
                })
            },
            initzybcp(){
                materialBreed_list({
                    materialType: '中药饮片(半成品)',
                    searchName: this.searchNamezybcp,
                    page: this.currentPagezybcp,
                }).then((res) =>{
                    this.tableData = res.rows
                    this.totalzybcp = res.total
                    for(var i=0;i<this.tableData.length;i++){
                        if(this.tableData[i].ypCodeStandard == 1){
                            this.tableData[i].ypCodeStandard = "国标"
                        }else if(this.tableData[i].ypCodeStandard == 2){
                            this.tableData[i].ypCodeStandard = "省标"
                        }
                    }
                })
            },
			init5(){
                materialBreed_list({
                    materialType: '配方颗粒(浸膏粉)',
                    searchName: this.searchName5,
                    page: this.currentPage5,
                }).then((res) =>{
                    this.tableData = res.rows
                    this.total5 = res.total
                    for(var i=0;i<this.tableData.length;i++){
                        if(this.tableData[i].ypCodeStandard == 1){
                            this.tableData[i].ypCodeStandard = "国标"
                        }else if(this.tableData[i].ypCodeStandard == 2){
                            this.tableData[i].ypCodeStandard = "省标"
                        }
                    }
                })
            },
            // tabs
            handleClick(tab, event) {
                this.materialType = tab.label
                if (this.materialType == '中药材') {
                    this.init1()
                } else if(this.materialType == '辅料') {
                    this.init2()
                } else if(this.materialType == '提取饮片'){
                    this.init3()
                } else if(this.materialType == '配方颗粒'){
                    this.init4()
                }else if(this.materialType == '配方颗粒(浸膏粉)'){
                    this.init5()
                }else if(this.materialType == '配方颗粒(颗粒)'){
                    this.init6()
                }else if(this.materialType == '中药饮片'){
                    this.initzy()
                }else if(this.materialType == '中药饮片(半成品)'){
                    this.initzybcp()
                }

            },
            // 物料编辑
            handleEdit(index,row){
                console.log(row);
                this.$router.push({
                    path:'/materialsManagement/edit',
                    query:{
                        id: row.id,
                        type:this.materialType
                    }
                })
            },
            // 查看物料
            handleView(index,row){
                this.$router.push({
                    path:'/materialsManagement/viewed',
                    query:{
                        id: row.id
                    }
                })
            },
            // 删除物料
            handleDelete(index,row){
                this.$confirm('此操作将永久删除该条数据, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    materialBreed_delete(row.id).then((res)=>{
                        this.tableData.splice(row,1)
                        this.$notify({
                            title: '操作成功',
                            message: '删除成功',
                            type: 'success'
                        });
                    })
                });
            },
            // 模板下载
            download() {
            let data = {
              type:this.materialType
            }
              axios({
                method: 'post',
                data:data,
                url: '/materialBreed/downTemplate',
                responseType: 'blob'
              }).then(res=>{
                // console.log(res)
                this.downloadFile(res, '数据.xls')
              }).catch(err=>{
                // console.log(err)
              })
                // window.location.href = "http://" + window.location.host + "/muban.xlsx";
                // window.location.href = "http://47.104.241.124:8901/muban.xlsx";
            },
            // 列表搜索
            handleSearch1() {
                this.currentPage1 = 1
                this.init1()
            },
            handleSearch2() {
                this.currentPage2 = 1
                this.init2()
            },
            handleSearch3() {
                this.currentPage3 = 1
                this.init3()
            },
            handleSearch4() {
                this.currentPage4 = 1
                this.init4()
            },
			handleSearch5() {
			    this.currentPage5 = 1
			    this.init5()
			},
            handleSearch6() {
                this.currentPage6 = 1
                this.init6()
            },
            handleSearchzy(){
                this.currentPagezy = 1
                this.initzy()
            },
            handleSearchzybcp(){
                this.currentPagezybcp = 1
                this.initzybcp()
            },
            // 禁用
            isOk(index,row){
                materialBreed_updateStatus({
                    id: row.id,
                    status: 1
                }).then((res) =>{
                    if (res.code == 200) {
                        this.$notify({
                            title: '操作成功',
                            message: '已禁用',
                            type: 'success'
                        });
                        if (row.materialType == '中药材') {
                            this.init1();
                        } else if (row.materialType == '辅料') {
                            this.init2();
                        } else if (row.materialType == '提取饮片') {
                            this.init3();
                        } else if (row.materialType == '配方颗粒') {
                            this.init4();
                        } else if (row.materialType == '配方颗粒(浸膏粉)') {
                            this.init5();
                        } else if (row.materialType == '配方颗粒(颗粒)') {
                            this.init6();
                        }else if (row.materialType == '中药饮片(半成品)') {
                            this.initzybcp();
                        }else if (row.materialType == '中药饮片') {
                            this.initzy();
                        }
                    }
                })
            },
            // 启用
            isNo(index,row){
                materialBreed_updateStatus({
                    id: row.id,
                    status: 0
                }).then((res) =>{
                    this.$notify({
                        title: '操作成功',
                        message: '已启用',
                        type: 'success'
                    });
                    if (row.materialType == '中药材') {
                        this.init1();
                    } else if (row.materialType == '辅料') {
                        this.init2();
                    } else if (row.materialType == '提取饮片') {
                        this.init3();
                    } else if (row.materialType == '配方颗粒') {
                        this.init4();
                    }else if (row.materialType == '配方颗粒(浸膏粉)') {
                        this.init5();
                    } else if (row.materialType == '配方颗粒(颗粒)') {
                        this.init6();
                    }else if (row.materialType == '中药饮片(半成品)') {
                        this.initzybcp();
                    }else if (row.materialType == '中药饮片') {
                        this.initzy();
                    }
                })
            },
            // 分页事件
            handleCurrentChange1(val){
                this.currentPage1 = val
                this.init1()
            },
            handleCurrentChange2(val){
                this.currentPage2 = val
                this.init2()
            },
            handleCurrentChange3(val){
                this.currentPage3 = val
                this.init3()
            },
            handleCurrentChange4(val){
                this.currentPage4 = val
                this.init4()
            },
			handleCurrentChange5(val){
			    this.currentPage5 = val
			    this.init5()
			},
            handleCurrentChange6(val){
                this.currentPage6 = val
                this.init6()
            },
            handleCurrentChangezy(val){
                this.currentPagezy = val
                this.initzy()
            },
            handleCurrentChangezybcp(val){
                this.currentPagezybcp = val
                this.initzybcp()
            },
             uploadonchange(file) {
				 const loading = this.$loading({
				   lock: true,
				   text: '导入中，请勿刷新页面',
				   spinner: 'el-icon-loading',
				   background: 'rgba(0, 0, 0, 0.7)'
				 });
                let formData = new FormData();
                formData.append('file', file.raw);
                let config = {
                    headers:{'Content-Type':'multipart/form-data'}
                };
               // /materialBreed/importManually
               mater_daoru(formData).then((res) =>{
                    if (res.code == 200) {
						 loading.close();
                        this.$alert('已导入'+res.data+'条', '导入成功', {
                            confirmButtonText: '确定',
                            callback: action => {

                            }
                        });

                        this.init()
                    } else{
						loading.close();
                        this.$notify.error({
                            title: '操作失败',
                            message: '导入失败',
                            type: 'error'
                        });
                    }
                })
            }
        }
    }
</script>

<style lang="less" scoped>
// 深度作用器
/deep/.upload-daoru{
    .el-upload{
        border: none;
        width: auto;
        height: auto;
        border-radius: 0;
        float: right;
        margin-right: 10px
    }
}
.el-col{
    margin-bottom: 0;
}
/* .scopClass .el-table{ margin-top: 20px;} */
 .el-pagination{
    text-align: center;
}
/*
.el-select .el-input {
width: 130px;
}
.input-with-select .el-input-group__prepend {
background-color: #fff;
}
.el-input--small .el-input__inner{
    border-radius: 5px 0 0 5px !important;
    border-right: none;
} */
</style>
